package bdqn;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Created by 旧 on 2018/8/4.
 */
public class Test {
    public static void main(String[] args) {

        Student eryao1 = null;
        Student eryao2 = null;
        Student eryao3 = null;
        Student eryao4 = null;

        Class<?> obj = null;
        try {
            obj = Class.forName("bdqn.Student");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Constructor<?>[] cs = obj.getConstructors();
        for (int i = 0; i <cs.length ; i++) {
            System.out.println(cs[i]);
        }
        Method[] methods=obj.getMethods();
        for (int i = 0; i < methods.length; i++) {
            System.out.println(methods[i]);
        }

    }
    }

  /*
    Class<?>[] inters=obj.getInterfaces();
        for (int i = 0; i <inters.length ; i++) {
            System.out.println(inters[i].getName());
        }
        Class super0=obj.getSuperclass();
        System.out.println("super0.getName()"+super0.getName());



  Constructor<?>[] cs=obj.getConstructors();
        try {
            eryao3 = (Student) cs[0].newInstance(12);
            eryao2 = (Student) cs[1].newInstance("二药");
            eryao1= (Student) cs[3].newInstance("二药",12);
            eryao4 = (Student) cs[2].newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
            System.out.println(eryao1);
            System.out.println(eryao2);
            System.out.println(eryao3);
            System.out.println(eryao4);
  }
  Class<?> obj = null;
        try {
            obj= Class.forName("bdqn.Student");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Student erryao=null;
        try {
            erryao=(Student) obj.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        erryao.setName=("二药");
        erryao.setAge(12);

        System.out.println(obj.toString());
        System.out.println(erryao.toString());*/
